<html>
  <script>
    var openedWindow = null;
    function openNewWindowOrClose() {
      if (openedWindow == null) {
        openedWindow = window.open('about:blank', '');
      } else {
        openedWindow.close();
        openedWindow = null;
      }
    }
  </script>
  <body onclick="openNewWindowOrClose();">
    <p>some content</p>
  </body>
</html>
